#pragma warning(disable:4996)
#pragma warning(disable:6031)

#include <iostream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int pre(char op)
{
	if (op == '+' || op == '-')
		return 1;
	if (op == '*' || op == '/')
		return 2;
	if (op == '(')
		return 0;
	return -1;
}

int com(int a, int b, char op)
{
	if (op == '+')
		return a + b;
	if (op == '-')
		return a - b;
	if (op == '*')
		return a * b;
	if (op == '/')
		return a / b;
	return 0;
}

int expression_evaluation(const string& exp)
{
	stack<int> val;
	stack<char> ops;
	for (int i = 0; i < exp.size(); i++)
	{
		if (exp[i] >= '0' && exp[i] <= '9')
		{
			int v = 0;
			while (i < exp.size() && exp[i] >= '0' && exp[i] <= '9')
			{
				v = (v * 10) + exp[i] - '0';
				i++;
			}
			i--;
			val.push(v);
		}
		else if (exp[i] == '(')
		{
			ops.push(exp[i]);
		}
		else if (exp[i] == ')')
		{
			while (!ops.empty() && ops.top() != '(')
			{
				int b = val.top();
				val.pop();
				char op = ops.top();
				ops.pop();
				int a = val.top();
				val.pop();
				val.push(com(a, b, op));
			}
			if (!ops.empty()) ops.pop();
		}
		else if (exp[i] == '+' || exp[i] == '-' || exp[i] == '*' || exp[i] == '/')
		{
			while (!ops.empty() && pre(ops.top()) >= pre(exp[i]))
			{
				int b = val.top();
				val.pop();
				char op = ops.top();
				ops.pop();
				int a = val.top();
				val.pop();
				val.push(com(a, b, op));
			}
			ops.push(exp[i]);
		}
		else if (exp[i] == '=')
		{
			while (!ops.empty())
			{
				int b = val.top();
				val.pop();
				char op = ops.top();
				ops.pop();
				int a = val.top();
				val.pop();
				val.push(com(a, b, op));
			}
			break;
		}
	}
	return val.top();
}

int main()
{
	string input;
	vector<int> v;
	while (1)
	{
		getline(cin, input);
		if (input == "=")
		{
			break;
		}
		v.push_back(expression_evaluation(input));
		input.clear();
	}
	for (auto e : v)
	{
		cout << e << endl;
	}
	return 0;
}